import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterialCategoryVO, MaterialCategoryForm, MaterialCategoryQuery } from '@/api/manu/materialCategory/types';

/**
 * 查询物料类别列表
 * @param query
 * @returns {*}
 */

export const listMaterialCategory = (query?: MaterialCategoryQuery): AxiosPromise<MaterialCategoryVO[]> => {
  return request({
    url: '/manu/materialCategory/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询物料类别详细
 * @param id
 */
export const getMaterialCategory = (id: string | number): AxiosPromise<MaterialCategoryVO> => {
  return request({
    url: '/manu/materialCategory/' + id,
    method: 'get'
  });
};

/**
 * 新增物料类别
 * @param data
 */
export const addMaterialCategory = (data: MaterialCategoryForm) => {
  return request({
    url: '/manu/materialCategory',
    method: 'post',
    data: data
  });
};

/**
 * 修改物料类别
 * @param data
 */
export const updateMaterialCategory = (data: MaterialCategoryForm) => {
  return request({
    url: '/manu/materialCategory',
    method: 'put',
    data: data
  });
};

/**
 * 删除物料类别
 * @param id
 */
export const delMaterialCategory = (id: string | number | Array<string | number>) => {
  return request({
    url: '/manu/materialCategory/' + id,
    method: 'delete'
  });
};
